package com.codebuffer.nowcoder;

import java.util.HashSet;
import java.util.Set;

public class DeleteDuplication {

    public ListNode deleteDuplication(ListNode pHead) {


        ListNode head  = new ListNode(-1);
        ListNode now = head;
        ListNode pernow = head;
        int val = -1;
        while(pHead!=null){
           if(pHead.val == val){
               pernow.next = pHead.next.next;
               pHead = pHead.next.next;
               now = pernow;
           }else {
               pernow = now;
               now.next = pHead;
               now = now.next;
               pHead = pHead.next;
               val = now.val;
           }
        }

        return head.next;
    }
}
class ListNode {
    int val;
    ListNode next = null;

    ListNode(int val) {
        this.val = val;
    }
}